<template>
  <el-tooltip :content="label" placement="top" :open-delay="1000" :enterable="false">
    <el-button :type="bType" @click="handleClick" :circle="true" style="height: 28px;">
      <i :class="iconType" style="font-size: 12px;"></i>
    </el-button>
  </el-tooltip>
</template>
<script>
    export default {
      name: 'operationBtn', // 行内操作按钮，宽度建议 41 * 按钮个数
      props: {
        label: {
          type: String
        },
        btnType: {
          type: String,
          default: 'add'
        }
      },
      computed: {
        bType() {
          switch (this.btnType) {
            case 'add': return ''
            case 'edit': return ''
            case 'delete': return 'danger'
            case 'confirm': return 'primary'
            case 'cancel': return ''
            case 'query': return 'primary'
            case 'save': return 'primary'
            case 'plus': return 'primary'
            case 'minus': return 'danger'
            case 'pre':return ''
            case 'next':return ''
            default: return ''
          }
        },
        iconType() {
          switch (this.btnType) {
            case 'add':
              return 'el-icon-circle-plus-outline'
            case 'edit':
              return 'el-icon-edit-outline'
            case 'delete':
              return 'el-icon-delete'
            case 'confirm':
              return 'el-icon-check'
            case 'pre':
              return 'el-icon-d-arrow-left'
            case 'next':
              return 'el-icon-d-arrow-right'
            case 'cancel':
              return 'el-icon-close'
            case 'query':
              return 'el-icon-search'
            case 'set':
              return 'el-icon-setting'
            case 'save':
              return 'el-icon-document'
            case 'append':
              return 'el-icon-check'
            case 'plus':
              return 'el-icon-plus'
            case 'minus':
              return 'el-icon-minus'
            case 'call':
              return 'el-icon-phone-outline'
            case 'resetPassword':
              return 'iconfont icon-resetPassword'
            case 'logOff':
              return 'iconfont icon-logOff'
            case 'remove':
              return 'iconfont icon-remove'
            case 'view':
              return 'el-icon-view'
            case 'restore':
              return 'iconfont icon-restore'
            default: return ''
          }
        }
      },
      methods: {
        handleClick() {
          this.$emit('btn-click')
        }
      }
    }
</script>